#include "metric.h"

Metric::Metric()
{

}

QString Metric::find(QString &route, const QString &variable)
{
    auto var = route.trimmed();
    auto index = var.indexOf(variable);
    if (index < 0) {
        return QString();
    }

    var = var.mid(index);
    auto splits = var.split(" ");
    if (splits.length() < 2) {
        return QString();
    }

    return splits.at(1);
}

int Metric::metric(QString &route)
{
    auto metric = find_metric(route).toInt();
    return metric;
}

QString Metric::find_metric(QString &route)
{
    return find(route, "metric");
}
